#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<assert.h>


int my_strcmp(const char* str1, const char* str2)
{
	assert(str1 && str2);
	while (*str1 == *str2)
	{
		if (*str1 == '\0')
		{
			return 0;
		}
		str1++;
		str2++;
	}
	if (*str1 > *str2)
	{
		return 1;
	}
	else 
	{
		return -1;
	}
	
}

char* my_strstr(const char* str1, const char* str2) {
	assert(str1 && str2);
	if (*str2 == '\0') return (char*)str1;

	const char* s1 = str1;
	while (*s1) 
	{
		const char* p1 = s1;
		const char* p2 = str2;
		while (*p1 && *p2 && (*p1 == *p2)) 
		{
			p1++;
			p2++;
		}
		if (*p2 == '\0') 
			return (char*)s1;
		s1++;
	}
	return NULL;
}

int main()
{
	char arr1[] = "abcdef";
	char arr2[] = "abcdef";
	char arr3[] = "bcd";
	/*int r1 = my_strcmp(arr1, arr2);
	int r2 = my_strcmp(arr1, arr3);
	int r3 = my_strcmp(arr3, arr1);*/
	/*printf("%d\n", r1);
	printf("%d\n", r2);
	printf("%d\n", r3);*/
	char* p = my_strstr(arr1, arr3);
	for (int i = 0;i < 5;i++)
	{
		printf("%c", *(p+i));
	}
	return 0;
}
